package RevolCraft.Renderers;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.lwjgl.opengl.GL11;

import RevolCraft.Models.ModelDefaultBlock;
import RevolCraft.Models.ModelHeart;

import net.minecraft.src.ItemStack;
import net.minecraft.src.ModelRenderer;
import net.minecraft.src.RenderBlocks;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import net.minecraftforge.client.IItemRenderer;

public class MachineBlockRenderer extends TileEntitySpecialRenderer {

	private static ModelDefaultBlock model;
	private static ModelHeart modelh;
	private static boolean JemimmaBirthday = false;
	private float angle = 0;
	
	static
	{
		Calendar date = new GregorianCalendar();
		date.setTimeInMillis(System.currentTimeMillis());
		
		modelh = new ModelHeart();
		model = new ModelDefaultBlock();
		
		if(date.get(date.MONTH) == Calendar.NOVEMBER && date.get(date.DAY_OF_MONTH) == 8)
				JemimmaBirthday = true;
	}
	
	@Override
	public void renderTileEntityAt(TileEntity par1, double par2, double par4, double par6, float par8)
	{
		if(JemimmaBirthday)
			this.bindTextureByName("/RevolCraft/Resources/Heart.png");
		else
			this.bindTextureByName(par1.getBlockType().getTextureFile());
		GL11.glPushMatrix();
		GL11.glTranslatef((float)par2 + 0.5F, (float)par4 + 1.5F, (float)par6 + 0.5F);
		GL11.glRotatef(-par1.getBlockMetadata()*90 - 180, 0.F, 1.F, 0.F);
		GL11.glScalef(1.0F, -1.0F, -1.0F);
		if(JemimmaBirthday)
		{
			GL11.glRotatef(angle, 0.F, 1.F, 0.F);
			angle++;
			modelh.renderAll();
		}
		else
			model.renderAll();
		GL11.glPopMatrix();
	}
}
